package io.renren.modules.gengyun.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.gengyun.entity.IndicatorInfoEntity;
import io.renren.modules.gengyun.service.IndicatorInfoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author
 * @email
 * @date 2020-09-21 19:34:06
 */
@RestController
@RequestMapping("gengyun/indicatorinfo")
public class IndicatorInfoController {
    @Autowired
    private IndicatorInfoService indicatorInfoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("gengyun:indicatorinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = indicatorInfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("gengyun:indicatorinfo:info")
    public R info(@PathVariable("id") Integer id){
		IndicatorInfoEntity indicatorInfo = indicatorInfoService.getById(id);

        return R.ok().put("indicatorInfo", indicatorInfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("gengyun:indicatorinfo:save")
    public R save(@RequestBody IndicatorInfoEntity indicatorInfo){
		indicatorInfoService.save(indicatorInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("gengyun:indicatorinfo:update")
    public R update(@RequestBody IndicatorInfoEntity indicatorInfo){
		indicatorInfoService.updateById(indicatorInfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("gengyun:indicatorinfo:delete")
    public R delete(@RequestBody Integer[] ids){
		indicatorInfoService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }


    @RequestMapping("/selectTarget")
    @RequiresPermissions("gengyun:indicatorinfo:delete")
    public R allTarget(@RequestParam Map<String, Object> params ){

        String target = (String) params.get("target");
        indicatorInfoService.getIndicatorNames(target);

        return R.ok();
    }



}
